import pandas as pd
import matplotlib.pyplot as plt
import random
import numpy as np
import seaborn as sns


plt.rcParams['font.sans-serif'] = ['KaiTi'] # 指定默认字体
plt.rcParams['axes.unicode_minus'] = False # 解决保存图像是负号'-'显示为方块的问题


def drawDataheatMap():
       # # arr = np.load('../data/matrix_data/matrix_win_60.npy')
       # for i in range(1200, 1290):
       #        arr1 = np.load('../data/matrix_data_base/test_data/test_data_'+str(i)+'.npy')
       #        arr2 = np.load('../data/matrix_data_base/reconstructed_data/reconstructed_data_'+str(i)+'.npy')
       #        arr1 = arr1[4][0]
       #        arr2 = np.transpose(arr2[0], [0, 3, 1, 2])
       #        arr2 = arr2[0][0]
       #
       #        error = np.square(np.subtract(arr1, arr2))
       #        # input
       #        sns.set()
       #        ax = sns.heatmap(arr1)
       #        plt.show()
       #        # Output
       #        sns.set()
       #        ax = sns.heatmap(arr2)
       #        plt.show()
       #        # error
       #        sns.set()
       #        ax = sns.heatmap(error)
       #        plt.show()

       # error = np.load('../rs/AE-M_error.npy') # 误差
       # error = np.reshape(error,(error.shape[0], error.shape[1], error.shape[2]))
       # for i in range(700, 709):
       #     sns.set()
       #     sns.heatmap(error[i])
       #     # plt.show()
       #     plt.savefig('../rs/error3/error'+str(i)+'.png', dpi=300)
       #     plt.show()
       #
       # for i in range(900, 909):
       #     sns.set()
       #     sns.heatmap(error[i])
       #     # plt.show()
       #     plt.savefig('../rs/error4/error'+str(i)+'.png', dpi=300)
       #     plt.show()
       arr = np.load('../rs/AE-M_error.npy')
       for i in range(arr.shape[0]):
              tmp = np.reshape(arr[i], (15, 15))
              # sns.set()
              # sns.heatmap(tmp)
              # plt.show()
              np.savetxt('../rs/error_txt/'+str(i+1)+'.txt', tmp, fmt='%f')



def drawDataBasic():
       title=['左高低',
              '右高低',
              '左轨向',
              '右轨向',
              '轨距',
              '超高',
              '水平',
              '三角坑',
              '曲率',
              '左高低长波',
              '右高低长波',
              '左轨向长波',
              '右轨向长波',
              '横加',
              '垂加']

       arr = pd.read_csv('../data/data_1804_(15,20000)_3.csv', header=None).values
       # arr = pd.read_csv('../data/data_testAno.csv',header=None).values

       arr = arr[:, 10000:]
       # mm级别
       for i in range(13):
              if i!=8:
                     plt.plot(arr[i, :], label=title[i])

       plt.legend(loc='right')
       plt.xlabel('点数')
       plt.ylabel('值/mm')
       plt.show()

       # cvtr
       plt.plot(arr[8, :], label=title[8])
       plt.legend(loc='right')
       plt.xlabel('点数')
       plt.ylabel('值/radpkm')
       plt.show()

       # vacc and lacc
       plt.plot(arr[13, :], label=title[13])
       plt.plot(arr[14, :], label=title[14])
       plt.legend(loc='right')
       plt.xlabel('点数')
       plt.ylabel('值/g')
       plt.show()


if __name__=='__main__':
      # drawDataBasic()
       drawDataheatMap()